import store from "@/store";
import $t from "@/z/function/$t";
import defaultValue from "@/z/function/defaultValue";
// import timeFormat from '@/z/function/timeFormat'
let timeFormat = uni.$u.timeFormat;
// import UPW from '../../json/UPW'
let searchjson = [{
		label: $t("卡号"),
		value: "printid",
	},
	{
		label: $t("卡类型"),
		value: "type",
		type: "select",
		option: [{
				label: $t("全部"),
				value: "",
			},
			...defaultValue.cardtype.filter((e) => {
				return [2].find((f) => {
					return e.value == f;
				});
			}),
		],
	},
	{
		label: $t("所属站点"),
		value: "pcs",
		type: "pcs",
	},
];
let tablejson = [{
		label: $t("印刷卡号"),
		value: "printid",
	},
	{
		label: $t("金额"),
		value: "je",
		callbackasync: async (data) => {
			if (!data.printid) {
				return "";
			}
			let card = await store.dispatch("request/getRequest", {
				url: "/Card",
				data: {
					printid: data.printid,
				},
			});
			let e = card.length == 1 ? card[0] : data;
			if (e.type == 1 || e.type == 4 || e.type == 3 || e.type == 6) {
				return e.je + $t("次");
			} else if (e.type == 5) {
				return (e.je / 60).toFixed(1) + $t("小时");
			} else if (e.type == 2) {
				return e.je / 100 + $t("元");
			}
		},
	},
	{
		label: $t("卡类型"),
		value: "type",
		type: "select",
		option: [...defaultValue.cardtype],
	},
	{
		label: $t("状态"),
		value: "zt",
		callbackasync: async (data) => {
			if (!data.printid) {
				return "";
			}
			let card = await store.dispatch("request/getRequest", {
				url: "/Card",
				data: {
					printid: data.printid,
				},
			});
			return card.length == 1 ? $t("已激活") : $t("未激活");
		},
	},
	{
		label: $t("所属站点"),
		value: "pcs",
		type: "pcs",
		callbackasync: async (data) => {
			let r = await store.dispatch("station/getstationfn", data.pcs);
			return r.length == 1 ? r[0].pcs : "";
		},
	},
];
let addjson = [{
		value: "printid",
		label: $t("卡号"),
	},
	{
		value: "type",
		label: $t("卡类型"),
		type: "select",
		option: [
			...defaultValue.cardtype.filter((e) => {
				return [1, 2, 4, 5, 6].find((f) => {
					return e.value == f;
				});
			}),
		],
		defaultValue: "2",
	},
	{
		callbackasync: async () => {
			let r = [{
					value: "je",
					label: $t("默认金额"),
					if: {
						zhi: [{
							value: "type",
							zhi: ["2"],
						}, ],
					},
					fl: 100,
					defaultValue: "0",
					dw: $t("元"),
				},

				{
					value: "je",
					label: $t("卡内次数"),
					if: {
						zhi: [{
							value: "type",
							zhi: ["1"],
						}, ],
					},
					dw: $t("次"),
				},
			];
			return r;
		},
	},

	{
		value: "yzdys",
		label: $t("费用标准"),
		defaultValue: "25",
		dw: $t("次"),
		span: 8,
		if: {
			zhi: [{
				value: "type",
				zhi: ["1"],
			}, ],
		},
	},
	{
		value: "yfy",
		label: "",
		labelwidth: "auto",
		fl: "100",
		defaultValue: "30",
		span: 4,
		dw: $t("元"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["1"],
			}, ],
		},
	},
	{
		value: "je",
		label: $t("次数"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
		dw: $t("次/日"),
	},
	{
		value: "yxq",
		label: $t("有效期"),
		dw: $t("月"),
		placeholder: $t("长期有效"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["2", "6"],
			}, ],
		},
	},
	{
		value: "yys",
		label: $t("赠送月份"),
		dw: $t("月"),
		defaultValue: "0",
		if: {
			zhi: [{
				value: "type",
				zhi: ["4", 5],
			}, ],
		},
	},
	{
		value: "yzdys",
		label: $t("费用标准"),

		dw: $t("月"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["4", "5"],
			}, ],
		},
		span: 6,
		defaultValue: 1,
	},
	{
		value: "je",
		labelwidth: "auto",
		dw: $t("次"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["4"],
			}, ],
		},
		span: 3,
		defaultValue: 25,
	},
	{
		value: "je",
		labelwidth: "auto",
		dw: $t("时"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["5"],
			}, ],
		},
		span: 3,
		fl: "60",
		defaultValue: 18,
	},
	{
		value: "yfy",

		dw: $t("元"),
		fl: "100",
		labelwidth: "auto",
		if: {
			zhi: [{
				value: "type",
				zhi: ["4", "5"],
			}, ],
		},
		span: 3,
		defaultValue: 30,
	},
	{
		label: $t("到期时间"),
		value: "yxq",
		if: {
			zhi: [{
				value: "type",
				zhi: ["5"],
			}, ],
		},

		defaultValue: "0",
		type: "select",
		option: [{
				label: $t("按充值时间到期"),
				value: "0",
			},
			{
				label: $t("按月底到期"),
				value: "1",
			},
			{
				label: $t("按激活时间到期"),
				value: "2",
			},
		],
	},
	{
		label: $t("是否续费"),
		value: "yys",
		if: {
			zhimust: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
		defaultValue: "0",
		type: "select",
		option: [{
				label: $t("否"),
				value: "0",
			},
			{
				label: $t("是"),
				value: "1",
			},
		],
	},
	{
		label: $t("续费金额"),
		value: "yfy",
		fl: "100",
		dw: $t("元"),
		if: {
			zhi: [{
				value: "yys",
				zhi: ["1"],
			}, ],
			zhimust: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
		defaultValue: "300",
	},
	{
		label: $t("续费月份"),
		value: "yzdys",
		dw: $t("月"),
		if: {
			zhi: [{
				value: "yys",
				zhi: ["1"],
			}, ],
			zhimust: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
		defaultValue: "12",
	},
	{
		value: "pcs",
		label: $t("使用站点"),
		type: "pcs",
		defaultValue: store.state.user.USearch.pcs,
	},
];
// yxq  类型6到期卡是否动用续费 0-不可以续费，1-可以续费
// yfy  类型6到期卡，续费金额
// yzdys 类型6到期卡，续费月份
let Cardedtjson = [{
		label: $t("卡号"),
		value: "printid",
		disabled: "disabled",
	},
	{
		label: $t("卡类型"),
		value: "type",
		disabled: "disabled",
		type: "select",
		option: [...defaultValue.cardtype],
	},
	{
		label: $t("使用站点"),
		value: "pcs",
		type: "pcs",
		disabled: "disabled",
	},
	{
		callback: (formdata, data) => {
			if (!data.sjs) {
				return [];
			}
			let defaultValue = new Date(data.sjs);
			defaultValue.setMonth(defaultValue.getMonth() + (Number(data.yys) + 1));
			if (data.yxq == "1") {
				defaultValue.setDate(1);
			}
			defaultValue = timeFormat(defaultValue);
			// console.log(defaultValue, 'defaultValue')
			// timefn
			return {
				label: $t("到期时间"),
				value: "dqsj",
				disabled: "disabled",
				if: {
					zhi: [{
						value: "type",
						zhi: ["5"],
					}, ],
				},
				defaultValue,
			};
		},
	},
	{
		label: $t("余额"),
		value: "je",
		fl: "100",
		dw: $t("元"),
		disabled: "disabled",
		if: {
			zhi: [{
				value: "type",
				zhi: ["2"],
			}, ],
		},
	},
	{
		label: $t("次数"),
		value: "je",
		dw: $t("次/日"),
		disabled: "disabled",
		if: {
			zhi: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
	},
	{
		label: $t("剩余次数"),
		value: "je",
		dw: $t("次"),
		disabled: "disabled",
		if: {
			zhi: [{
				value: "type",
				zhi: ["1", "4"],
			}, ],
		},
	},
	{
		label: "剩余时间",
		value: "je",
		// fl: '60',
		dw: $t("分钟"),
		disabled: "disabled",
		if: {
			zhi: [{
				value: "type",
				zhi: ["5"],
			}, ],
		},
	},
	{
		label: $t("姓名"),
		value: "uxm",
	},
	{
		label: $t("电话"),
		value: "utel",
	},

	{
		label: $t("有效期"),
		value: "sje",
		type: "calendar",
		itemtype: "date",
		placeholder: $t("永久有效"),
		disabledDate: (time) => {
			return time.getTime() < Date.now();
		},
		if: {
			zhi: [{
				value: "type",
				zhi: ["2", "6"],
			}, ],
		},
	},

	// {
	// 	label: '赠送月份',
	// 	value: 'yys',
	// 	if: {
	// 		zhi: [{
	// 			value: 'type',
	// 			zhi: ['4', '5']
	// 		}]
	// 	},
	// 	defaultValue: '0',
	// },
	{
		label: $t("是否续费"),
		value: "yys",
		if: {
			zhimust: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
		defaultValue: "0",
		type: "select",
		option: [{
				label: $t("否"),
				value: "0",
			},
			{
				label: $t("是"),
				value: "1",
			},
		],
	},
	{
		label: $t("续费金额"),
		value: "yfy",
		fl: "100",
		dw: $t("元"),
		if: {
			zhi: [{
				value: "yys",
				zhi: ["1"],
			}, ],
			zhimust: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
		defaultValue: "300",
	},
	{
		label: $t("续费月份"),
		value: "yzdys",
		dw: $t("月"),
		if: {
			zhi: [{
				value: "yys",
				zhi: ["1"],
			}, ],
			zhimust: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
		defaultValue: "12",
	},
	{
		label: $t("备注"),
		value: "bz",
	},
];
let CardsPLedt = [{
		value: "type",
		label: $t("卡类型"),
		type: "select",
		option: [
			...defaultValue.cardtype.filter((e) => {
				return [1, 2, 4, 5, 6].find((f) => {
					return e.value == f;
				});
			}),
		],
		defaultValue: "2",
	},

	{
		callbackasync: async () => {
			let USearchStation = await store.dispatch("station/getstationfn");
			USearchStation = USearchStation.length == 1 ? USearchStation[0] : {};
			let user = store.state.user.USearch;
			let jeczfalg =
				USearchStation.b_cardcz &&
				(user.udj == "0" || user.udj == "1" || !user.udj);

			if (!(jeczfalg && store.getters["upw/b_cardcz"])) {
				return [];
			}
			let r = [{
					value: "je",
					label: $t("默认金额"),
					if: {
						zhi: [{
							value: "type",
							zhi: ["2"],
						}, ],
					},
					fl: 100,
					defaultValue: "0",
					dw: $t("元"),
				},

				{
					value: "je",
					label: $t("卡内次数"),
					if: {
						zhi: [{
							value: "type",
							zhi: ["1"],
						}, ],
					},
					dw: $t("次"),
				},
			];
			return r;
		},
	},

	{
		value: "yzdys",
		label: $t("费用标准"),
		defaultValue: "25",
		dw: $t("次"),
		span: 8,
		if: {
			zhi: [{
				value: "type",
				zhi: ["1"],
			}, ],
		},
	},
	{
		value: "yfy",
		label: "",
		labelwidth: "auto",
		fl: "100",
		defaultValue: "30",
		span: 4,
		dw: $t("元"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["1"],
			}, ],
		},
	},
	{
		value: "je",
		label: $t("次数"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
		dw: $t("次/日"),
	},
	{
		value: "yxq",
		label: $t("有效期"),
		dw: $t("月"),
		placeholder: $t("长期有效"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["2", "6"],
			}, ],
		},
	},
	{
		value: "yys",
		label: $t("赠送月份"),
		dw: $t("月"),
		defaultValue: "0",
		if: {
			zhi: [{
				value: "type",
				zhi: ["4", 5],
			}, ],
		},
	},
	{
		value: "yzdys",
		label: $t("费用标准"),

		dw: $t("月"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["4", "5"],
			}, ],
		},
		span: 6,
		defaultValue: 1,
	},
	{
		value: "je",
		labelwidth: "auto",
		dw: $t("次"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["4"],
			}, ],
		},
		span: 3,
		defaultValue: 25,
	},
	{
		value: "je",
		labelwidth: "auto",
		dw: $t("时"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["5"],
			}, ],
		},
		span: 3,
		fl: "60",
		defaultValue: 18,
	},
	{
		value: "yfy",

		dw: $t("元"),
		fl: "100",
		labelwidth: "auto",
		if: {
			zhi: [{
				value: "type",
				zhi: ["4", "5"],
			}, ],
		},
		span: 3,
		defaultValue: 30,
	},
	{
		label: $t("到期时间"),
		value: "yxq",
		if: {
			zhi: [{
				value: "type",
				zhi: ["5"],
			}, ],
		},

		defaultValue: "0",
		type: "select",
		option: defaultValue.yxq,
	},
	{
		value: "pcs",
		label: $t("使用站点"),
		type: "pcs",
		defaultValue: store.state.user.USearch.pcs,
	},

	{
		value: "printidstart",
		label: $t("开始卡号"),
	},
	{
		value: "printidend",
		label: $t("结束卡号"),
	},
];
let CardsPLedtexcel = [{
		value: "type",
		label: $t("卡类型"),
		type: "select",
		option: [
			...defaultValue.cardtype.filter((e) => {
				return [1, 2, 4, 5, 6].find((f) => {
					return e.value == f;
				});
			}),
		],
		defaultValue: "2",
	},

	{
		callbackasync: async () => {
			let USearchStation = await store.dispatch("station/getstationfn");
			USearchStation = USearchStation.length == 1 ? USearchStation[0] : {};
			let user = store.state.user.USearch;
			let jeczfalg =
				USearchStation.b_cardcz &&
				(user.udj == "0" || user.udj == "1" || !user.udj);
			if (!(jeczfalg && store.getters["upw/b_cardcz"])) {
				return [];
			}
			let r = [{
					value: "je",
					label: $t("默认金额"),
					if: {
						zhi: [{
							value: "type",
							zhi: ["2"],
						}, ],
					},
					fl: 100,
					defaultValue: "0",
					dw: $t("元"),
				},

				{
					value: "je",
					label: $t("卡内次数"),
					if: {
						zhi: [{
							value: "type",
							zhi: ["1"],
						}, ],
					},
					dw: $t("次"),
				},
			];
			return r;
		},
	},

	{
		value: "yzdys",
		label: $t("费用标准"),
		defaultValue: "25",
		dw: $t("次"),
		span: 8,
		if: {
			zhi: [{
				value: "type",
				zhi: ["1"],
			}, ],
		},
	},
	{
		value: "yfy",
		label: "",
		labelwidth: "auto",
		fl: "100",
		defaultValue: "30",
		span: 4,
		dw: $t("元"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["1"],
			}, ],
		},
	},
	{
		value: "je",
		label: $t("次数"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["6"],
			}, ],
		},
		dw: $t("次/日"),
	},
	{
		value: "yxq",
		label: $t("有效期"),
		dw: $t("月"),
		placeholder: $t("长期有效"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["2", "6"],
			}, ],
		},
	},
	{
		value: "yys",
		label: $t("赠送月份"),
		dw: $t("月"),
		defaultValue: "0",
		if: {
			zhi: [{
				value: "type",
				zhi: ["4", 5],
			}, ],
		},
	},
	{
		value: "yzdys",
		label: $t("费用标准"),

		dw: $t("月"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["4", "5"],
			}, ],
		},
		span: 6,
		defaultValue: 1,
	},
	{
		value: "je",
		labelwidth: "auto",
		dw: $t("次"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["4"],
			}, ],
		},
		span: 3,
		defaultValue: 25,
	},
	{
		value: "je",
		labelwidth: "auto",
		dw: $t("时"),
		if: {
			zhi: [{
				value: "type",
				zhi: ["5"],
			}, ],
		},
		span: 3,
		fl: "60",
		defaultValue: 18,
	},
	{
		value: "yfy",

		dw: $t("元"),
		fl: "100",
		labelwidth: "auto",
		if: {
			zhi: [{
				value: "type",
				zhi: ["4", "5"],
			}, ],
		},
		span: 3,
		defaultValue: 30,
	},
	{
		label: $t("到期时间"),
		value: "yxq",
		if: {
			zhi: [{
				value: "type",
				zhi: ["5"],
			}, ],
		},

		defaultValue: "0",
		type: "select",
		option: defaultValue.yxq,
	},
	{
		value: "pcs",
		label: $t("使用站点"),
		type: "pcs",
		defaultValue: store.state.user.USearch.pcs,
	},

	{
		label: $t("选择Excel"),
		value: "excel",
		type: "excel",
		defaultValue: "",
		span: 24,
		rule: [{
			required: true,
			message: $t("请选择Excel"),
			trigger: "blur",
		}, ],
		mapdata: [{
			label: $t("卡号"),
			value: "printid",
		}, ],
	},
];
export default {
	CardsPLedtexcel,
	CardsPLedt,
	Cardedtjson,
	addjson,
	searchjson,
	tablejson,
	exceldata: tablejson,
};